import QueryPanel from "./QueryPanel"
import GraphPanel from "./GraphPanel"
import { useState } from "react"

export default function GraphAnalysis () {

    const [selectedAssociationMethod, setSelectedAssociationMethod] = useState(() => (undefined))
    const [selectedLitigant, setSelectedLitigant] = useState(() => (undefined))
    const [selectedResource, setSelectedResource] = useState(() => (undefined))
    const [selectedCode, setSelectedCode] = useState(() => (undefined))
    const [selectedType, setSelectedType] = useState(() => (undefined))
    const [selectedId, setSelectedId] = useState(() => (undefined))
    const [selectedOccurrenceTime, setSelectedOccurrenceTime] = useState(() => (undefined))

    const queryHandle = ({
        selectedAssociationMethod,
        selectedLitigant,
        selectedResource,
        selectedCode,
        selectedType,
        selectedId,
        selectedOccurrenceTime,
    }) => {
        setSelectedAssociationMethod(() => (selectedAssociationMethod))
        setSelectedLitigant(() => (selectedLitigant))
        setSelectedResource(() => (selectedResource))
        setSelectedCode(() => (selectedCode))
        setSelectedType(() => (selectedType))
        setSelectedId(() => (selectedId))
        setSelectedOccurrenceTime(() => (selectedOccurrenceTime))
    }

    return (
        <>
            <div>
                <QueryPanel queryHandle={queryHandle}/>
            </div>
            <GraphPanel 
                selectedAssociationMethod={selectedAssociationMethod}
                selectedLitigant={selectedLitigant}
                selectedResource={selectedResource}
                selectedCode={selectedCode}
                selectedType={selectedType}
                selectedId={selectedId}
                selectedOccurrenceTime={selectedOccurrenceTime}
            />
        </>
    )
}